﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace Chaos.model
{
    public class region : INotifyPropertyChanged, stream.streamable
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void Notify(string property)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }

        private String m_name;
        public String Name
        {
            get { return m_name; }
            set
            {
                if (m_name != value)
                {
                    m_name = value;
                    Notify("Name");
                }
            }
        }

        private bool m_populoustag;
        public bool Populoustag
        {
            get { return m_populoustag; }
            set
            {
                if (m_populoustag != value)
                {
                    m_populoustag = value;
                    Notify("Populoustag");
                }
            }
        }

        private int m_resistanceandconquestvalue;
        public int Resistanceandconquestvalue
        {
            get { return m_resistanceandconquestvalue; }
            set
            {
                if (m_resistanceandconquestvalue != value)
                {
                    m_resistanceandconquestvalue = value;
                    Notify("Resistanceandconquestvalue");
                }
            }
        }         

        private ObservableCollection<chaoscardspace> m_chaoscardspaces = new ObservableCollection<chaoscardspace>();
        public ObservableCollection<chaoscardspace> Chaoscardspaces
        {
            get { return m_chaoscardspaces; }
            set
            {
                if (m_chaoscardspaces != value)
                {
                    m_chaoscardspaces = value;
                    Notify("Chaoscardspaces");
                }
            }
        }

        private ObservableCollection<stream.streamable> m_regionarea = new ObservableCollection<stream.streamable>();
        public ObservableCollection<stream.streamable> Regionarea
        {
            get { return m_regionarea; }
            set
            {
                if (m_regionarea != value)
                {
                    m_regionarea = value;
                    Notify("Regionarea");
                }
            }
        }  

        public virtual void serialize(stream.stream io_Stream)
        {
            io_Stream.begin("region")
                .serialize("Name", ref m_name)
                .serialize("Resistanceandconquestvalue", ref m_resistanceandconquestvalue)
                .serialize("Chaoscardspaces", ref m_chaoscardspaces)
                // .serialize("Regionarea", ref m_regionarea)
            .end();
        }
    }
}
